//
//import java.util.HashSet;
//import java.util.Scanner;
//
//public class Main {
//    public static void main(String[] args) {
//        Scanner scanner = new Scanner(System.in);
//        int n = scanner.nextInt();
//        HashSet<Integer> set = new HashSet<>();
//        int max = Integer.MIN_VALUE, min = Integer.MAX_VALUE;
//        int ret1 = 0, ret2 = 0;
//        while(scanner.hasNextInt()) {
//            int x = scanner.nextInt();
//            if(set.contains(x)) {
//                ret2 = x;
//            }
//            set.add(x);
//            max = Math.max(x, max);
//            min = Math.min(x,min);
//        }
//
//        for(int i = min; i<= max; i++) {
//            if(!set.contains(i)) {
//                ret1 = i;
//                break;
//            }
//        }
//
//        System.out.println(ret1 + " " + ret2);
//    }
//}


import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int w = scanner.nextInt();
        int m = scanner.nextInt();
        int n = scanner.nextInt();
        // 计算n,m所在行
        int hm = (m-1) / w, hn = (n-1) / w;
        // 计算n,m所在列
        int lm = 0;
        if (hm % 2 == 0) {
            lm = (m-1) % w;
        } else {
            lm = w - (m-1) % w - 1;
        }

        int ln = 0;
        if (hn % 2 == 0) {
            ln =( n-1) % w;
        } else {
            ln = w - (n-1) % w - 1;
        }

        //System.out.println("lm:" + lm + " ln:" + ln + " hm:" + hm + " hn:" + hn);

        System.out.println(Math.abs(lm - ln) + Math.abs(hm - hn));
    }
}